home *** CD-ROM | disk | FTP | other *** search
- Path: engnews1.Eng.Sun.COM!taumet!clamage
- From: abell@mindspring.com (Andrew Bell)
- Newsgroups: comp.std.c++
- Subject: Re: Is RTTI required if polymorphic constructor exists
- Date: 19 Apr 1996 14:43:45 GMT
- Organization: MindSpring Enterprises
- Approved: clamage@eng.sun.com (comp.std.c++)
- Message-ID: <4l72i4$1js6@mule1.mindspring.com>
- References: <4kng7f$kt9@nuscc.nus.sg>
- NNTP-Posting-Host: taumet.eng.sun.com
- X-Nntp-Posting-Host: abell.mindspring.com
- X-Newsreader: Forte Agent .99.82
- Content-Length: 1388
- X-Lines: 33
- Originator: clamage@taumet
-
- satrajit@iscs.nus.sg (Satrajit Sujit Ghosh) wrote:
- > If a polymorphic constructor can be created as demonstrated below,
- >is RTTI really necessary, considering that it does not really provide a
- >great deal of information.
-
- I don't understand particularly how your sample code makes RTTI less
- useful. One place RTTI is handy is if you have an interaction between
- two classes, where knowing the exact type of each class can lead to
- optimizations.
-
- For example, you might have a generic bitmap class, which returns an
- RGB value for each pixel, and you want to copy one bitmap to another.
- A derived class from your bitmap class might be a class that
- represents a 256 color bitmap, with an overloaded copy operator. If
- you leave the bitmap you're copying as the generic type, then you need
- to obtain the RGB value for a pixel, find the closest match in your
- palette, and assign the pixel that palette index. But if you know the
- bitmap you're copying from is also a 256 color bitmap, you can build a
- conversion table between matching palette indices, and do a much
- faster copy.*
-
- One problem, though, is that you may not care about the actual class
- of an object, but just whether it is derived from (or is) of a
- particular class, and RTTI doesn't help you there.
-
- Andrew Bell
- abell@mindspring.com
-
- * For real quality, you want to dither your data, and thus this
- algorithm wouldn't hold.
-
-
-
-
-
- [ comp.std.c++ is moderated. To submit articles: try just posting with ]
- [ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
- [ FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html ]
- [ Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
- [ Comments? mailto:std-c++-request@ncar.ucar.edu ]
-